Enable both Python 2 and Python 3 in Jupyter Notebook

Creating the working environment on the machine can be painful. I am using Homebrew for python packages management, it works great. The cons are Homebrew takes over the PATH, the directory which the computer reads and writes docs. Through its possible to change the PATH but not that straightforward.

Python 2 will not be maintained soon. The future is Python 3. But sometimes you will need to work in Python 2, as needed. Or the legacy codes were written in Python 2 and its too costly for you to move to Python 3. Meanwhile most of the packages went to Python 3 but some are still in Python 2. At the moment its nice to have both.

I have both Python 2 and Python 3 installed. But when I call Jupyter Notebook only Python 2 can be launched. I tried few things untill I found this post on Stackoverflow Using both Python 2.x and Python 3.x in IPython Notebook

A person wanted use Python 2 and Python 3 in the notebook. I tried one of the answers by the user “lsh”

If you?re running Jupyter on Python 3, you can set up a Python 2 kernel like this:

python2 -m pip install ipykernel

python2 -m ipykernel install –user
http://ipython.readthedocs.io/en/stable/install/kernel_install.html

I have Python 2 and what I wanted is Python 3, so I changed “python2” into “python3” in both commands and executed them in the terminal. When I launch Jupyter Notebook, I can choose Python 2 or Python 3.